package com.nce.entity;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;


/**
 *论坛 博客
 * @author GT
 */
@Entity
@Table(name = "bbs_blog")
//默认的缓存策略.
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class BbsBlog extends BaseNews {
	
	private static final long serialVersionUID = 5013560204171709314L;

	/*
	 CREATE TABLE `bbs_blog` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(255) default NULL,#标题
  `content` mediumtext,#内容
  `url` varchar(255) default NULL,#链接
  `tm_post` datetime default NULL,#发文时间
  `forum_name` varchar(255) default NULL,#论坛名
  `author` varchar(255) default NULL,#作者
  `author_info` varchar(255) default NULL,#作者信息
  `rply_cnt` mediumint(9) default NULL,#回复数
  `read_cnt` mediumint(9) default NULL,#点击数
  `uid` mediumint(9) default NULL,#文章所属的用户
  `tm_spider` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `tm_last_rply` datetime default NULL,
  `Is_New ` varchar(255) default NULL,#新文章标志
  `Has_Export` varchar(255) default NULL,#导出标志
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
	 */
	
	
	private Date tmLastRply;
	private String author;
	private String authorInfo;
	private Long rplyCnt;
	private Long readCnt;
	
	
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public String getAuthorInfo() {
		return authorInfo;
	}
	public void setAuthorInfo(String authorInfo) {
		this.authorInfo = authorInfo;
	}
	public Long getRplyCnt() {
		return rplyCnt;
	}
	public void setRplyCnt(Long rplyCnt) {
		this.rplyCnt = rplyCnt;
	}
	public Long getReadCnt() {
		return readCnt;
	}
	public void setReadCnt(Long readCnt) {
		this.readCnt = readCnt;
	}
	@Override
	public String toString() {
		return "BbsBlog [author=" + author + ", authorInfo=" + authorInfo
				+ ", rplyCnt=" + rplyCnt + ", readCnt=" + readCnt
				+ ", getTitle()=" + getTitle() + ", getContent()="
				+ getContent() + ", getUrl()=" + getUrl() + ", getTmPost()="
				+ getTmPost() + ", getForumName()=" + getForumName()
				+ ", getUser()=" + getUser() + ", getTmSpider()="
				+ getTmSpider() + ", getTmLastRply()=" + getTmLastRply()
				+ ", getIsNew()=" + getIsNew() + ", getHasExport()="
				+ getHasExport() + ", toString()=" + super.toString()
				+ ", getId()=" + getId() + ", getClass()=" + getClass()
				+ ", hashCode()=" + hashCode() + "]";
	}
	
	public Date getTmLastRply() {
		return tmLastRply;
	}
	public void setTmLastRply(Date tmLastRply) {
		this.tmLastRply = tmLastRply;
	}
	//String result = "标题,链接,发文媒体,发文时间,浏览数,回复数,作者,作者信息,内容摘要\r\n";
	public String formatForExport(){
		StringBuilder sb = new StringBuilder();
		sb.append("\"").append(getTitle()).append("\",");
		sb.append("\"").append(getUrl()).append("\",");
		sb.append("\"").append(getForumName()).append("\",");
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		sb.append("\"").append(df.format(getTmPost())).append("\",");
		
		sb.append(getReadCnt()).append(",");
		sb.append(getRplyCnt()).append(",");
		sb.append("\"").append(getAuthor()).append("\",");
		sb.append("\"").append(getAuthorInfo()).append("\",");
		sb.append("\"").append(getContent()).append("\",");
		sb.append("\r\n");
		return sb.toString();
	}	
	
	
	
}
